//封装wx请求的函数
export default function request (url,data,method='GET'){
  return new Promise((resolve,reject)=>{
    wx.request({
      url: "http://localhost:3000"+ url,
      data,
      header:{
        cookie: wx.getStorageSync('cookie') && wx.getStorageSync('cookie').join(';')
      },
      method,
      success:(res)=>{
        if(data.islogin){
          console.log(res);
          wx.setStorageSync('cookie', res.cookies)
        }
        resolve(res.data)
      },
      fail:(error)=>{
        reject(error)
      }
    })
  })
}